﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using DataModel.Managers;
using DataModel.Models;
using System.Linq;

namespace UniversityPortal.Controllers
{
    public class ListController : Controller
    {
        public ActionResult WeekDay()
        {
            var selectedWeekDayId = ControllerContext.ParentActionViewContext.ViewData.Model as short?;

            var genres = new List<WeekDayModel>
            {
                new WeekDayModel { DayNumber = 1, DayName = "Monday" },
                new WeekDayModel { DayNumber = 2, DayName = "Tuesday" },
                new WeekDayModel { DayNumber = 3, DayName = "Wednesday" },
                new WeekDayModel { DayNumber = 4, DayName = "Thursday" },
                new WeekDayModel { DayNumber = 5, DayName = "Friday" },
                new WeekDayModel { DayNumber = 6, DayName = "Saturday" },
                new WeekDayModel { DayNumber = 7, DayName = "Sunday" }
            };

            var model = new SelectList(genres, "DayNumber", "DayName", selectedWeekDayId);

            ViewData.Model = model;
            ViewData.ModelMetadata = ControllerContext.ParentActionViewContext.ViewData.ModelMetadata;

            return View("DropDown");
        }


        public ActionResult Subject()
        {
            var selectedSubjectId = ControllerContext.ParentActionViewContext.ViewData.Model as Guid?;

            var sManager = new SubjectManager();
            var subjects = sManager.GetAllSubjects();

            var model = new SelectList(subjects, "SubjectID", "FullName", selectedSubjectId);

            ViewData.Model = model;
            ViewData.ModelMetadata = ControllerContext.ParentActionViewContext.ViewData.ModelMetadata;

            return View("DropDown");
        }

        public ActionResult Professor()
        {
            var selectedProfessorId = ControllerContext.ParentActionViewContext.ViewData.Model as Guid?;

            var uManager = new UserManager();
            var professors = uManager.GetAllProfessors();

            var model = new SelectList(professors, "ID", "LastName", selectedProfessorId);

            ViewData.Model = model;
            ViewData.ModelMetadata = ControllerContext.ParentActionViewContext.ViewData.ModelMetadata;

            return View("DropDown");
        }


        public ActionResult Auditory()
        {
            var selectedAuditoryId = ControllerContext.ParentActionViewContext.ViewData.Model as Guid?;

            var aManager = new AuditoryManager();
            var auditories = aManager.GetAllAuditories();

            var model = new SelectList(auditories, "ID", "FullName", selectedAuditoryId);

            ViewData.Model = model;
            ViewData.ModelMetadata = ControllerContext.ParentActionViewContext.ViewData.ModelMetadata;

            return View("DropDown");
        }

        public ActionResult LessonType()
        {
            var selectedLessonTypeId = ControllerContext.ParentActionViewContext.ViewData.Model as Guid?;

            var lManager = new LessonManager();
            var lessonTypes = lManager.GetLessonTypes();

            var model = new SelectList(lessonTypes, "ID", "Name", selectedLessonTypeId);

            ViewData.Model = model;
            ViewData.ModelMetadata = ControllerContext.ParentActionViewContext.ViewData.ModelMetadata;

            return View("DropDown");
        }

        public ActionResult Group()
        {
            var selectedGroupTypeId = ControllerContext.ParentActionViewContext.ViewData.Model as Guid?;

            var groupManager = new GroupManager();
            var groupsInStudy = groupManager.GetAllGroups().Where(g => g.IsStudy);

            var model = new SelectList(groupsInStudy, "Id", "Number", selectedGroupTypeId);

            ViewData.Model = model;
            ViewData.ModelMetadata = ControllerContext.ParentActionViewContext.ViewData.ModelMetadata;

            return View("DropDown");
        }


    }
}
